package com.xAdmin.service;


import org.springframework.ai.chat.ChatClient;
import org.springframework.ai.chat.messages.UserMessage;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Administrator
 */
@Service
public class AiService {
    private final ChatClient chatClient;

    // 使用构造函数注入
    @Autowired
    public AiService(ChatClient chatClient) {
        this.chatClient = chatClient;
    }
//
//
    public String testMessage(String message) {
        Prompt prompt = new Prompt(new UserMessage(message));
        return chatClient.call(prompt).getResult().getOutput().getContent();
    }
}
